<?php
	/*ini_set("display_errors","1");
	error_reporting(E_ALL);*/
	require_once("../config.php");
	require_once("cClientePhone.php");
	
	$tipoMapas = array('mobile', 'satellite', 'terrain', 'hybrid');
	$tablaId = $_REQUEST['tablaId'];
	$objetivo = $_REQUEST['objetivo'];
	$aliasId = $_REQUEST['aliasId'];
	
	if ($aliasId == NULL || trim($aliasId) == '') {
		$aliasId = $tablaId;
	}
	$datosCuenta = BykomClientePhone::Info_Alias_Phone($aliasId, $objetivo);
	//$gmapkey = $datosCuenta->campo('gmapkey',0);
	//$gmapkey = "ABQIAAAAb2cIl05JoEQ0tItv9ddwVBTYIvJQgRp2fkbTivtJ0-K9on5_qhQj9k1Tz7wiJYq_GK2nWiSYoKSn1w";
	$gmapkey = GMAP_KEY;
	$datosMovil = BykomClientePhone::Info_Movil($tablaId);
	$datosPosicionamiento = BykomClientePhone::Info_Posicion_Movil($tablaId);
   	if ($datosPosicionamiento->cantidad() < 1) {
   		exit("El movil no posee posicion actual.");
   	}
   	
   	$longitud = trim(BykomClientePhone::quitCero($datosPosicionamiento->campo('LONGITUD',0)));
	$latitud = trim(BykomClientePhone::quitCero($datosPosicionamiento->campo('LATITUD',0)));
	$zoom = $_REQUEST['zoom'];
	if (!isset($zoom)) {
		$zoom = $datosCuenta->campo('zoom',0);
		if ($zoom == NULL || trim($zoom) == '') {
			$zoom = 14;
		}
	}
	
	$maptype = $_REQUEST['maptype'];
	if (!isset($maptype)) {
		$maptype = $datosCuenta->campo('maptype',0);
		if ($maptype == NULL || trim($maptype) == '') {
			$maptype = "mobile";
		}
	}
	
	$width = 220;
	$height = 170;
	
	if (isset($_REQUEST['heigthDiv']) && $_REQUEST['heigthDiv'] != 0) {
		$height = $_REQUEST['heigthDiv'];
	}
	if (isset($_REQUEST['widthDiv']) && $_REQUEST['widthDiv'] != 0) {
		$width = $_REQUEST['widthDiv'];
	}
   	$URLMapa = "http://maps.google.com/staticmap?center=" .$latitud ."," . $longitud . 
						   "&zoom=" . $zoom . "&size=" . $width . "x" . $height . 
						   "&maptype=" . $maptype . "&key=" . $gmapkey . "&sensor=true&" .
						   "markers=" . $latitud ."," . $longitud .",blue&" .
						   "format=png";
							   
	
	//echo $URLMapa;					  
   	
?>	

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Bykom Web Cliente</title>
	<link rel="stylesheet" href="css/phone.css" type="text/css" media="screen" charset="utf-8"/>
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">
<div class="bodyContent">

<form name="filtroEventos" action="mapaCell.php">
<input type="hidden" name="tablaId" id="tablaId" value="<?=$tablaId?>">
<input type="hidden" name="aliasId" id="aliasId" value="<?=$aliasId?>">
<input type="hidden" name="objetivo" id="objetivo" value="<?=$objetivo?>">
<input type="hidden" name="zoom" id="zoom" value="<?=$zoom?>">
<input type="hidden" name="maptype" id="maptype" value="<?=$maptype?>">

<div class="top">	

	<table width="100%">
		<tr>
			<td class="labelTop">
				<span class="textTop"> <?= $datosMovil->campo('patente', 0);?>  </span>  
			</td>
            <td rowspan="2" width="105px" align="center" valign="middle">
            	<img src="images/WClogoTop.gif" border="0">
            </td>
		</tr>
		
	</table>
</div>
<div class="botonera">
	<table align="left">
		<tr>
			<td class="labelTop">
            	Mapeo
            </td>
		</tr>
	</table>
	
	<table align="right" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td align="right"> 
        		<a href="movilCell.php?tablaId=<?=$tablaId?>&objetivo=<?=$objetivo?>&aliasId=<?=$aliasId?>" title="Volver"><img src="images/BTNback.gif" border="0"/></a> 			
			</td>
			<td align="right"> 
        		<a href="welcomeCell.php" title="Salir/Logout"><img src="images/BTNexit.gif" border="0"/></a> 			
			</td>
		</tr>	
	</table>
</div>


<table>
	<tr>
		<td class="label">
			Zoom: <select name="zoom" id="zoom">
			<? 
			for ($i = 1; $i < 19; $i++) {
				$selected = "";
				if ($zoom == $i) {
					$selected = "selected";
				}
				echo "<option value='" . $i . "' " . $selected . ">" . $i . "</option>";
			}
			?>
			</select>
		</td>
		<td class="label">
			Tipo: <select name="maptype" id="maptype">
			<? for ($i = 0; $i < count($tipoMapas); $i++) {
				$selected = "";
				if ($maptype == $tipoMapas[$i]) {
					$selected = "selected";
				}
				echo "<option value='" . $tipoMapas[$i] . "' " . $selected . ">" . $tipoMapas[$i] . "</option>";
			}
			?>
			</select>
		</td>
		<td>
        	<input type="submit" class="button" value="Refrescar"/>
        </td>                
	</tr>
	<tr>
		<td colspan="3" align="center">
			<img src="<?=$URLMapa?>" alt="mapa" border="1"/>
		</td>
	</tr>
</table>    
</form>

</div>
</td></tr></table>
</body>
</html>




